//
//  WelcomeViewController.swift
//  CXSwiftWB
//
//  Created by meidaeriOS on 2017/6/1.
//  Copyright © 2017年 meidaer. All rights reserved.
//

import UIKit

class WelcomeViewController: UIViewController {
    
    /// 头像底部约束
    @IBOutlet weak var bottomConstraint: NSLayoutConstraint!
    
    /// 标题
    @IBOutlet weak var iconImageView: UIImageView!
    /// 欢迎按钮
    @IBOutlet weak var welcomeLabel: UILabel!
    

    override func viewDidLoad() {
        super.viewDidLoad()
     //   assert(UserAccount.loadUserAccount() != nil, "用户当前还没有授权")
        iconImageView.setCornerRadius(radius: 45)
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        // 计算移动距离
        let offset = view.h - bottomConstraint.constant
        bottomConstraint.constant = offset
        
        // 执行头像动画
        UIView.animate(withDuration: 1.0, animations: { 
            self.view.layoutIfNeeded()
        }) { (_) in
            UIView.animate(withDuration: 1.0, animations: { 
                self.welcomeLabel.alpha = 1.0
            }, completion: { (_) in
                NotificationCenter.default.post(name: NSNotification.Name.init(switchRootViewControllerNotification), object: self, userInfo: nil)
            })
        }
    }
}
